package java8.stream.demo03filterstream;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

import static java.util.stream.Collectors.toList;

/**
 * @author ChangLiang
 * @date 2020/4/22
 */
public class AppTest {

    @Test
    @DisplayName("test filter list")
    public void test() {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 6, 7, 7, 1);

        System.out.println(list.stream().filter(i -> i % 2 == 0).collect(toList()));

        System.out.println(list.stream().distinct().collect(toList()));

        System.out.println(list.stream().skip(50).collect(toList()));

        System.out.println(list.stream().limit(50).collect(toList()));
    }
}
